package cn.wolfcode.trip.api.controller;

import cn.wolfcode.trip.base.domain.Chat;
import cn.wolfcode.trip.base.domain.ChatRecord;
import cn.wolfcode.trip.base.service.IChatRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/chatRecords")
public class ChatRecordController {

    @Autowired
    private IChatRecordService chatRecordService;

    /**
     * 查询发送者和接收者之间的聊天记录
     * @param chat
     * @return
     */
    @GetMapping("/{sender.id}/{receiver.id}/messages")
    public List queryChatRecord(Chat chat) {
        List<ChatRecord> list = chatRecordService.queryForList(chat);
        return list;
    }
}
